package com.infindo.appcreate.zzyj.entity;

import static javax.persistence.GenerationType.SEQUENCE;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.Transient;

import com.infindo.appcreate.zzyj.util.DateTimeUtil;
import com.infindo.appcreate.zzyj.util.StringUtil;

@Entity
@Table(name = "zzyj_project", schema = "public")
public class Project implements java.io.Serializable {

    private static final long serialVersionUID = 5836568984239431729L;
    
    private Long id;
    private String code;
    private String title;
    private Date time;
    private String timeF;//format time item
    private String user;
    private String place;
    private Integer score;
    private Integer expertScore;
    private Integer crowdScore;
    private String  listImage;
    //private String imagesSmall;
    private String promoteImages;
    //private String imagesBig;//no used
    private Integer promoteType;//0 image; 1 video
    private String desc;//contents contains tags
    private String descImage;//no used
    
    public Project(){
        
    }
    
    public Project(String code, String title, Date time, String user, String place, Integer expertScore, Integer score,
            Integer crowdScore, String listImage, String promoteImages, Integer promoteType, String desc){
        super();
        this.code = code;
        this.title = title;
        this.time = time;
        this.user = user;
        this.place = place;
        this.score = score;
        this.expertScore = expertScore;
        this.crowdScore = crowdScore;
        this.listImage = listImage;
        this.promoteImages = promoteImages;
        this.promoteType = promoteType;
        this.desc = desc;
        
    }

	@SequenceGenerator(name = "generator", sequenceName = "seq_zzyj_project",allocationSize=1)
	@Id
	@GeneratedValue(strategy = SEQUENCE, generator = "generator")
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    
    @Column(name = "title")
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    
    @Column(name = "time")
    public Date getTime() {
        return time;
    }
    public void setTime(Date time) {
        this.time = time;
    }
    
    @Column(name = "_user")
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    
    @Column(name = "place")
    public String getPlace() {
        return place;
    }
    public void setPlace(String place) {
        this.place = place;
    }
    
    @Column(name = "expert_score")
    public Integer getExpertScore() {
        return expertScore;
    }
    public void setExpertScore(Integer expertScore) {
        this.expertScore = expertScore;
    }
    
    @Column(name = "crowd_score")
    public Integer getCrowdScore() {
        return crowdScore;
    }
    public void setCrowdScore(Integer crowdScore) {
        this.crowdScore = crowdScore;
    }
    
    @Column(name = "list_image")
    public String getListImage() {
        return listImage;
    }
    public void setListImage(String listImage) {
        this.listImage = listImage;
    }
    
    @Column(name = "promote_images")
    public String getPromoteImages() {
        return promoteImages;
    }
    public void setPromoteImages(String promoteImages) {
        this.promoteImages = promoteImages;
    }
    
    @Column(name = "_desc")
    public String getDesc() {
        return desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
    
    @Column(name = "desc_image")
    public String getDescImage() {
        return descImage;
    }
    public void setDescImage(String descImage) {
        this.descImage = descImage;
    }
    
    @Column(name = "promote_type")
    public Integer getPromoteType() {
        return promoteType;
    }
    public void setPromoteType(Integer promoteType) {
        this.promoteType = promoteType;
    }

    @Column(name = "score")
    public Integer getScore() {
        return score;
    }
    public void setScore(Integer score) {
        this.score = score;
    }

    @Transient
	public String getTimeF() {
    	if(null != this.time){
    		return DateTimeUtil.DateToString("yyyy-MM-dd", this.time);
    	}
		return null;
	}
	public void setTimeF(String timeF) {
		this.timeF = timeF;
	}
	
}
